package cn.xinfei.xdecision;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;


@SpringBootApplication(exclude = {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class})
@EnableTransactionManagement
@ComponentScan(basePackages = "cn.xinfei.xdecision.**")
@EnableAsync
@EnableFeignClients
@EnableDiscoveryClient
@Slf4j
//@EnableAspectJAutoProxy(exposeProxy = true)
public class XDecisionEngineServerApplication {

    @Autowired
    ApplicationContext applicationContext;

    public static void main(String[] args) {
        try {
//            String property = System.getProperty("nacos.server.port", "8848");
//           log.info("nacos.server.port:{}",property);
            ConfigurableApplicationContext application = SpringApplication.run(XDecisionEngineServerApplication.class, args);
            Environment env = application.getEnvironment();
            String port = env.getProperty("server.port");
            log.info("\n=========== (♥◠‿◠)ﾉﾞ  >>>>>>>> 启动成功 <<<<<<<<   ლ(´ `)ლﾞ ===========\n" +
                    "Application is running! Access URLs:\n" +
                    "Local:       http://localhost:" + port + "/doc.html\n" +
                    "=======================================================================");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
